package com.example.administrator.hqq.activity.complain;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.hqq.R;
import com.example.administrator.hqq.base.MyActivity;
import com.example.administrator.hqq.bean.Complain;
import com.example.administrator.hqq.config.LoongsConfig;
import com.zhy.autolayout.AutoLinearLayout;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.w3c.dom.Comment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ComplaintsSuccessfullyActivity extends MyActivity {
    @BindView(R.id.quit_text)
    TextView quitText;
    @BindView(R.id.consider)
    Button consider;
    @BindView(R.id.quit)
    Button quit;
    @BindView(R.id.auto)
    AutoLinearLayout auto;
    @BindView(R.id.finish)
    Button finish;
    private String type;
    private String objectId;

    /**
     * @param context  上下文
     * @param type     投诉类型 用于判断页面展示和后续逻辑
     * @param objectId 被举报的id
     * @param id  聊天室targetId
     */
    public static void start(Context context, String type, String objectId,String id) {
        Intent starter = new Intent(context, ComplaintsSuccessfullyActivity.class);
        starter.putExtra(LoongsConfig.type, type);
        starter.putExtra(LoongsConfig.objectId, objectId);
        starter.putExtra(LoongsConfig.id,id);
        context.startActivity(starter);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_complaints_successfully);
        ButterKnife.bind(this);
        EventBus.getDefault().unregister(this);
        initview();
    }

    private void initview() {
        objectId = getIntent().getStringExtra(LoongsConfig.objectId);
        type = getIntent().getStringExtra(LoongsConfig.type);
        if (type.equals(LoongsConfig.ComplainType.GROUP.toString())) {
            auto.setVisibility(View.VISIBLE);
            quitText.setVisibility(View.VISIBLE);
        } else {
            finish.setVisibility(View.VISIBLE);
        }
    }

    @Override
    protected String getActivityName() {
        return null;
    }

    @OnClick({R.id.consider, R.id.quit, R.id.finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.consider:
                finish();
                break;
            case R.id.quit:
                Complain complain = new Complain(Complain.Type.QUIT_GROUP, objectId);
                EventBus.getDefault().post(complain);
                finish();
                break;
            case R.id.finish:
                clickFinish();
                finish();
                break;
        }
    }

    @Override
    public void onBackPressed() {
//        if (type.equals(LoongsConfig.ComplainType.QUIT_GROUP.toString())) {
//            //退出群聊
//            Complain complain = new Complain(Complain.Type.QUIT_GROUP, objectId);
//            EventBus.getDefault().post(complain);
//        } else if (type.equals(LoongsConfig.ComplainType.GROUP_MEMBER.toString())){
//            //提出群成员
//            Complain complain = new Complain(Complain.Type.KICK_MEMBER, objectId);
//            EventBus.getDefault().post(complain);
//        }
//        else if (type.equals(LoongsConfig.ComplainType.PRIVATE.toString())){
//            //删除联系人好友
//            Complain complain = new Complain(Complain.Type.DELETE_FRIEND, objectId);
//            EventBus.getDefault().post(complain);
//        }
        finish();
    }

    private void clickFinish() {

    }

    @Subscribe (threadMode = ThreadMode.MAIN)
    public void event(String s){

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
